<template>
  <div id="app">
    <Left class="left" :send="allData"></Left>
   <div v-if="allData[index]">
        <Right class="right" :send1="allData[index].children" ></Right>
   </div>
   
  </div>
</template>

<script>
import Left from "./components/left.vue";
import Right from "./components/right.vue";
import Data from "./data/data.js"
export default {
  data(){
      return {
          allData:[],
          index:0
      }
  },
  components: {
    Left,
    Right,
  },
  mounted() {
      console.log(Data);
      this.$axios.get("/list").then(res=>{
          console.log(res.data);
          this.allData = res.data
      })

      // 接收左边传过来的下标
      this.$bus.$on("sendIndex",(data)=>{
          this.index = data
      })
  }
};
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}
html,
body {
  width: 100%;
  height: 100%;
}
#app {
  width: 100%;
  height: 100%;
  background: red;
  display: flex;
}
.left {
  width: 150px;
  height: 100%;
  background: yellow;
}
.right {
  flex: 1;
}
</style>
